import React, {PureComponent} from 'react';
import {Form, Input, Modal, } from 'antd';
const FormItem = Form.Item;
const {TextArea} = Input;
//水印控制
const WaterOptions = [
  {label: '明文水印', value: '1'},
  {label: '屏幕水印', value: '2'},
  // {label: '暗水印', value: '3'},
  // {label: '打印水印', value: '4'},
];

/**
 * 外接文件申请下载页面
 */
@Form.create()
class OutfileDownloadApplyCreateForm extends PureComponent {
  constructor(props) {
    super(props);
    this.formLayout = {
      labelCol: {span: 4},
      wrapperCol: {span: 20},
    };
  }



  render() {
    const {modalVisible, form, addDownloadApply, handleModalVisible, record} = this.props;
    const okHandle = () => {
      form.validateFields((err, fieldsValue) => {
        if (err) return;
        form.resetFields();
        addDownloadApply(record,fieldsValue);
      });
    };

    let waterType =record.waterType;
    let waterTypeText = "";
    if (waterType) {
      waterType.forEach(item => {
        WaterOptions.forEach(water => {
          if (item == water.value) {
            waterTypeText = waterTypeText + water.label + ' ';
          }
        })
      })
    }

    return (
      <Modal
        width={640}
        bodyStyle={{padding: '32px 40px 48px'}}
        destroyOnClose
        title="下载申请"
        visible={modalVisible}
        onOk={okHandle}
        onCancel={() => handleModalVisible()}
        afterClose={() => handleModalVisible()}
        maskClosable={false}
      >

        <FormItem key="fileName" {...this.formLayout} label="文件名称">
          {record.dirName}
        </FormItem>
        <FormItem key="fileName" {...this.formLayout} label="生命周期">
          {record.life}
        </FormItem>
        <FormItem key="fileName" {...this.formLayout} label="权限控制">
          {record.authorize}
        </FormItem>
        <FormItem key="fileName" {...this.formLayout} label="水印控制">
          {waterTypeText?waterTypeText:'无'}
        </FormItem>
        <FormItem key="desc" {...this.formLayout} label="申请理由">
          {form.getFieldDecorator('applyReason', {
            rules: [{required: true, message: '申请理由不能为空', min: 5}],
          })(<TextArea rows={4} placeholder="请输入至少五个字符"/>)}
        </FormItem>
      </Modal>
    );
  }
}

export default OutfileDownloadApplyCreateForm;
